package com.jt.demo9;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
//当spring容器启动时,加载指定的配置文件,将数据保存到容器中
@PropertySource(value = "classpath:/dept.properties",encoding = "utf-8")
public class Dept {
    // @Value属性可以简单属性赋值
    //取值方式:从spring容器中获取数据${pro中的key}
    @Value("${dept.id}")
    private Integer id;
    @Value("${dept.name}")
    private  String name;
    public void hello(){
        System.out.println("获取数据:"+id+":"+name);
    }
}
